Impact 2024: The Industrial Data and AI Conference for and by Users | Nominate Speakers Now for a Ch...
Hello,When it comes to setting the `max-workers` for an SDK, you have a couple of options: Global Configuration: You can set global configurations that will apply to any instance of `CogniteClient` that is created after the global configurations have been set. Here's how you can set the `GlobalConfig`: from cognite.client import global_config, ClientConfigfrom cognite.client.credentials import Tokenglobal_config.default_client_config = ClientConfig( client_name="my-client", project="myproj", credentials=Token("verysecret"))global_config.max_workers = <desired_value> # Set the desired number for max_workersRemember, any configurations set in the `global_config` should be made prior to instantiating a `CogniteClient` to ensure they take effect.Directly in the CogniteClient Constructor: The documentation suggests that you can also pass a `ClientConfig` directly when you create a new `CogniteClient`. So, if you only want to set the `max_workers` for a specific instance, you can d
Hello! Thanks for reporting this. I agree the UI is a bit confusing here. When uploading your source code as a zip-file, this file is stored as a CDF File in the Files API. You might want this CDF file to be associated with a particular dataset. In that case, you can specify the ID of the dataset in the Dataset ID box. We’ll see if we can make this more clear in the UI. / Ivar
Hello again!This is slightly outside my area of expertise, but I will do my best to answer. The "Disable public access" setting in Azure Key Vault is a security measure designed to restrict all public network access. In our context, this means that any request coming from a Cognite Function, which falls outside the allowed IP addresses or virtual networks, will be blocked, regardless of the authentication method.Given this, there isn't a straightforward method to bypass this setting using any authentication approach, such as ClientSecretCredential. The network-level restriction set by "Disable public access" will always take precedence.While I understand this is far from ideal, you might need to deactivate the “Disable public access” to make this work. Before making any changes, it's essential to consider the security implications.Kind regards,Ivar
Hello again! Probable Cause: It seems you're using DefaultAzureCredential(), which can pull credentials from various sources (like environment variables, managed identities, etc.). If these sources aren't configured correctly, it can lead to such authentication issues.Suggested Solution: To address this, I recommend trying the ClientSecretCredential method, which allows for more specific authentication using your Azure AD tenant ID, client ID, and client secret. Here's a basic example of how to use it:def handle(client, data, secrets): tenant_id = "YOUR_TENANT_ID" client_id = "YOUR_CLIENT_ID" client_secret = secrets.get("YOUR_CLIENT_SECRET") credential = ClientSecretCredential(tenant_id=tenant_id, client_id=client_id, client_secret=client_secret) KEYVAULT_NAME = "kv-abc-01" KEYVAULT_URI = f"https://{KEYVAULT_NAME}.vault.azure.net" sc = SecretClient(vault_url=KEYVAULT_URI, credential=credential) CLIENT_ID = sc.get_secret("kvSCRT-d-ussc-01").valueYou would ha
Hello Saroj!Just so we can better understand your use case, you want the Cognite Function to be able to fetch confidential information from an Azure Key Vault when executing (for instance an API-key or a secret token)? Unfortunately, we do not have any Cognite specific documentation on how to do this, but you can certainly do this using the documentation Viraj linked to as well as the `azure.keyvault` and `azure-keyvault-secrets` SDK. Make sure you deploy your Cognite Function with the `azure-identity` and `azure-keyvault-secrets` package listed in the `requirements.txt`. Then within your handler, you can authenticate by various means. I recommend for instance the `ClientSecretCredential` method, but you would have to tailor this to your use case. Then within your handler, you can fetch the secret as such:from azure.keyvault.secrets import SecretClientfrom azure.identity import ... # credential type of choicedef handle(client, data): keyVaultName = data.get("keyvault_name") KVUri
Hello Eashwar! You would have to deploy some Python code to do this - note I haven’t tested this, but it should serve as a starting point for you. This requires the library `openpyxl` to be able to call `df.to_excel`.import pandas as pdimport iodef get_data_frame(): df = pd.DataFrame({ 'A': [1, 2, 3], 'B': [4, 5, 6], 'C': ['p', 'q', 'r'] }) return dfdef handle(client, data): # do some set up to fetch the data-frame dataframe = get_data_frame() # then you can convert the dataframe to xls-format. # to avoid storing directly to a file, we can use io.BytesIO() output_buffer = io.BytesIO() df.to_excel(output, sheet_name='my_sheet', index=False) # the FilesAPI accepts BytesIO as input in `client.files.create` client.files.upload_bytes(output_buffer, name="my_file", ...)I hope this helps! Let me know if you need further assistance.
Hello Czach! When you say “host a web-hook endpoint”, do you mean spinning up an API endpoint in the Cognite Function, for instance using Flask or FastAPI? Can you help me understand your specific use case? You won’t be able to keep this server alive, as each Cognite Function invocation has a specific execution time limit. Regards, Ivar Stangeby
Hello Peder!Currently, we do not support the granularity you are requiring in our ACLs as we only have read/write ACLs. Adding a `functionsAcl:CALL` should be sufficient to let you differentiate between users allowing to create/delete functions, and simply calling them. I will add this as a feature-request. / Ivar
Could you also please trigger 4525036003390684 again from the UI, or create a schedule on it?
Thanks! I’ll see if I can find any indication of what is wrong. By chance, does the function response / function logs give you any insights?
Hello! Could you also provide the CDF project name? Was function 4525036003390684 working fine a couple of hours ago, or a different function?
Already have an account? Login
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.
Sorry, we're still checking this file's contents to make sure it's safe to download. Please try again in a few minutes.
Sorry, our virus scanner detected that this file isn't safe to download.