How to set SAGEMAKER_SUBMIT_DIRECTORY environment variable in sagemaker - amazon-sagemaker

I am trying to deploy a model that i have registered. I registered the model using the following code:
step_register = RegisterModel(
name="RegisterCustomModel",
estimator=estimator,
model_data=step_train.properties.ModelArtifacts.S3ModelArtifacts,
content_types=["text/csv"],
response_types=["text/csv"],
inference_instances=["ml.t2.medium", "ml.m5.large"],
transform_instances=["ml.m5.large"],
model_package_group_name=model_package_group_name,
approval_status=model_approval_status,
model_metrics=model_metrics,
)
However, I am getting an error when i deploy this model which I believe is because the environment variable SAGEMAKER_SUBMIT_DIRECTORY is not set.
My question is, can I set the environment variable SAGEMAKER_SUBMIT_DIRECTORY in the RegisterModel function and if I can, how do I do that?

Related

Get env value to model laravel?

I have problem with date format in laravel model for different operating system (windows & linux) SQL Server
How to get the value from env to model, I create variable in .env for set condition in model when value variable environment 1 = windows and 2 = linux
// 1 FOR WINDOWS
// 2 FOR LINUX SERVER
ENVIRONMENT=1
Any solution / advice for this case?
All variables in your .env files are parsed as strings, so some reserved values have been created to allow you to return a wider range of types from the env() function.
make sure you already execute this command to clear your config after you added that variable to your config.
php artisan config:clear
Retrieving Environment Configuration
<?php
$environment = env("environment", 1)
?>
The second value passed to the env function is the "default value". This value will be used if no environment variable exists for the given key.
see docs here env
in Laravel function env() returns values from .env file.
So if you have ENVIROMENT = 1 in your .env, using env('ENVIRONMENT'), you will get that value.

Play-slick - Is default.db required?

I'm working on an application using Play and Slick. This app requires access to (at least) two databases and this is working fine when one is defined as default and other is named. Eg.,
db.default.driver = "com.mysql.jdbc.Driver"
db.default.url = "jdbc:mysql://localhost:3306/db1"
db.db2.driver = "com.mysql.jdbc.Driver"
db.db2.url = "jdbc:mysql://localhost:3306/db2"
I can then happily access each db as follows
DB.withSession { implicit session => ??? }
DB("db2").withSession { implicit session => ??? }
However, this doesn't really make sense as there is no reason DB1 should be the default. The DBs contain different types of data, neither is the default, both are important. What I would like is:
db.db1.driver = "com.mysql.jdbc.Driver"
db.db1.url = "jdbc:mysql://localhost:3306/db1"
db.db2.driver = "com.mysql.jdbc.Driver"
db.db2.url = "jdbc:mysql://localhost:3306/db2"
Play-scala barfs at this thought. It needs a default db driver and URL and it needs to be able to connect to it.
Anyone know anyway to change this behaviour or to trick play into thinking it has a default?
UPDATE
To be clear, I've greped my code to ensure that I'm not using DB.withSession anywhere. That is, every time I create a session I use DB("db1").withSession or DB("db2").withSession. However, when I run my test, I still get an exception:
Caused by: Configuration error: Configuration error[Slick error : jdbc driver not defined in application.conf for db.default.driver key]
Something somewhere is trying to load the default config.
Default is just a name, with some convenience functions (withSession and withTransaction without name), so, no you do not need to have a default connection if it does not fit your project.

Deploying from a development org to a new unrelated org without a package

I've been struggling with the deployment of our force.com application code that has, up to now, been developed in a single development org I'll call DevOrg.
What I want to do is transfer the DevOrg objects, code, pages, etc from DevOrg to a sandbox in a new org (NewOrg) that I have created. NewOrg and its sandbox are devoid of any code/objects related to the application. I've used the migration tool to retrieve the code from DevOrg and have fashioned the package.xml in various ways to get the code to deploy the NewOrg sandbox, but I keep getting tons of errors, for example:
[sf:deploy] SomeClass: line 1014, column 95: Dependent class is invalid and needs recompilation:
[sf:deploy] SomceClass2: line 475, column 37: Dependent class is invalid and needs recompilation:
I went into the Eclipse IDE and checked out the project from DevOrg, exported the project and imported it to a project pointed to NewOrg's sandbox. I thought perhaps this would give me hints about a working package.xml since I can work in the DevOrg project in the Eclipse IDE without any problems/errors.
But instead I found the same errors in the NewOrg sandbox project when loaded within the IDE. So I tried making adding a space to the dependent class and saving it to the NewOrg sandbox and I received an sObject error like this:
Save error:
sObject type 'SomeClass__c' is not supported.
If you are attempting to use a custom object, be sure to append the '__c' after the entity name.
Please reference your WSDL or the describe call for the appropriate names.
Thinking this must be because the objects haven't been deployed to NewOrg's sandbox, I attempted to the deploy only the objects in the project. That too failed. This time with errors like this:
Save error:
Appointment_Type_Form__c.Form__c : referenceTo value of 'Form_Template__c'
does not resolve to a valid sObject type Appointment_Type_Form__c.object
Save error:
Form__c : Cannot set ControlledByParent on a CustomObject without a
MasterDetail relationship field Form__c.object
Save error:
Form__c.All : In field: columns - no CustomField named
Form__c.Form_Template__c found Form__c.object
Save error:
Form__c.Form_Template__c : referenceTo value of 'Form_Template__c'
does not resolve to a valid sObject type Form__c.object
Save error:
Form_Template__c : formoverride does not exist or is not
a valid override for action Edit. Form_Template__c.object
Save error:
GWAPI_Log__c : log_detail does not exist or is not
a valid override for action View. GWAPI_Log__c.object
Save error:
Idea.Ideas_Last_7_Days : Could not resolve list
view column: IDEA.IDEA_THEME Idea.object
Save error:
Message__c.Form_in_Question__c : referenceTo value of 'Form_Template__c'
does not resolve to a valid sObject type Message__c.object
Save error:
News__c : customarticle does not exist or is not a valid override
for action Edit. News__c.object
Save error:
Question__c : Cannot set ControlledByParent on a CustomObject without
a MasterDetail relationship field Question__c.object
Save error:
Question__c.All : In field: columns - no CustomField named
Question__c.Form_Template__c found Question__c.object
Save error:
Question__c.Form_Template__c : referenceTo value of 'Form_Template__c'
does not resolve to a valid sObject type Question__c.object
Save error:
Section__c : Cannot set ControlledByParent on a CustomObject without
a MasterDetail relationship field Section__c.object
Save error:
Section__c.Form_Template__c : referenceTo value of 'Form_Template__c'
does not resolve to a valid sObject type Section__c.object
Save error:
Security_Question_Answer__c.Question_Text__c : Field Is_Patient__c
does not exist. Check spelling. Security_Question_Answer__c.object
Save error:
sObject type 'Portal_Session__c' is not supported. If you are
attempting to use a custom object, be sure to append the '__c'
after the entity name. Please reference your WSDL or the describe call for the appropriate names.
And so I have to have any luck with the new deployment in either the IDE or via the Migration Tool (MT).
I'm looking for advice on how to approach these issues when deploying to a brand new org using either IDE or MT. The errors imply, I think, something about the ordering of the deployment but as I understand from the Migration Tool Guide, Development Lifecycle Guide, etc the dependencies and ordering can be determined by the platform when deploying.
Have others run into similar issues and found that the solution was strictly in the package.xml? I'm curious because in one instance the package.xml works fine (when deploying to the original org) but in the other case (a new org) it doesn't seem sufficient.
The troubles with a virgin sandboxes is that usually you can't deploy it without a few iterations.
I used the following workflow:
deploy the custom objects which are on relationships with standard objects
deploy standard sObjects
deploy the rest of sObjects
deploy triggers and apex code
deploy VF pages/VF email templates
deploy the rest of metadata
after that I used only migration tool for deployment.
I'd like to suggest you perform deployment of sObjects by one at a time for most significant objects. Also before the deployment please check that all settings of standard objects conform to DevOrg's settings
Also you can try to change API version of metadata.

USERxx variables not usable in action_url and notes_url

I am using Nagios Core 3.5.0 and I have the following service definition:
service {
...
action_url http://$USER10$/static/html/node.html?node=$USER3$&host=$HOSTADDRESS$
}
The USERxx variables have been set correctly in resource.cfg.
However, the URL that gets generated does not get the value at all for the USER variables but gets the value for HOSTADDRESS.
Is there something that I need to do to all USER variables to be available for the action_url and notes_url?
The USER variables should definitely be available, as per here: Nagios 3.x manual
In fact, we're running Nagios 3.5.1 and have successfully done this to link to pnp4nagios graphs:
define host {
name host-pnp
action_url $USER10$?host=$HOSTNAME$
register 0
}
Have you defined the resource.cfg in your nagios.cfg correctly using something like this?
resource_file=/usr/local/nagios/etc/resource.cfg
My guess is that you've not defined the resource file correctly, so the macros are not being defined.

App Engine Instance ID

Is it possible to get info on what instance you're running on? I want to output just a simple identifier for which instance the code is currently running on for logging purposes.
Since there is no language tag, and seeing your profile history, I assume you are using GAE/J?
In that case, the instance ID information is embedded in one of the environment attributes that you could get via ApiProxy.getCurrentEnvironment() method. You could then extract the instance id from the resulting map using key BackendService.INSTANCE_ID_ENV_ATTRIBUTE.
Even though the key is stored in BackendService, this approach will also work for frontend instances. So in summary, the following code would fetch the instance ID for you:
String tInstanceId = ApiProxy.getCurrentEnvironment()
.getAttributes()
.get( BackendService.INSTANCE_ID_ENV_ATTRIBUTE )
.toString();
Please keep in mind that this approach is quite undocumented by Google, and might subject to change without warning in the future. But since your use case is only for logging, I think it would be sufficient for now.
With the advent of Modules, you can get the current instance id in a more elegant way:
ModulesServiceFactory.getModulesService().getCurrentInstanceId()
Even better, you should wrap the call in a try catch so that it will work correctly locally too.
Import this
import com.google.appengine.api.modules.ModulesException;
import com.google.appengine.api.modules.ModulesServiceFactory;
Then your method can run this
String instanceId = "unknown";
try{
instanceId = ModulesServiceFactory.getModulesService().getCurrentInstanceId();
} catch (ModulesException e){
instanceId = e.getMessage();
}
Without the try catch, you will get some nasty errors when running locally.
I have found this super useful for debugging when using endpoints mixed with pub-sub and other bits to try to determine why some things work differently and to determine if it is related to new instances.
Not sure about before, but today in 2021 the system environment variable GAE_INSTANCE appears to contain the instance id:
instanceId = System.getenv("GAE_INSTANCE")

Resources